<?
/*********************************************
*获取新闻栏目信息
* *******************************************/
function smarty_function_qishi_news_category($params, &$smarty)
{ 
extract($params);
global $db;
$listname = (NULL != $listname) ? $listname : 'list'; //默认的section名称
$row = (NULL != $row) ? $row : 15; //默认显示记录数量
$start  = (NULL != $start) ? $start : 0; //从第几条开始读取，缺省0
!empty($typeid)? $wheresqlarr['id']=intval($typeid):'';//跟据栏目ID获取栏目信息
!empty($classify)? $wheresqlarr['ParentID']=intval($classify):'';//跟据上级栏目获取新闻栏目
$titlelen = (NULL != $len) ? $titlelen : 15; //默认显示标题数量
$dot = (NULL != $dot) ? $dot : ''; //默认截取后填补字符
	if (is_array($wheresqlarr))
	{
	$where_set=' WHERE';
		foreach ($wheresqlarr as $key => $value)
		{
		$wheresql .=$where_set. $comma.'`'.$key.'`'.'=\''.$value.'\'';
		$comma = ' AND ';
		$where_set='';
		}
	}
if(!empty($row))
	{
	$offset=$start?$start:0;
	$limit=" LIMIT ".$offset.','.$row;
	}
$result = $db->query("SELECT * FROM ".table('article_category')." ".$wheresql.$limit);
while($row = $db->fetch_array($result))
{
$row['url']=url_rewrite("news-list",array('id0'=>"".$row['id'].""));
$row['title']=cut_str($row['categoryname'],$titlelen,0,$dot);
$row['categoryname']=cut_str($row['categoryname'],$titlelen,0,$dot);
$List[] = $row;
}
$smarty->assign($listname, $List);
unset($List);
}
?>